﻿Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports QBuilder



'''<summary>
'''This is a test class for InCriteriaTest and is intended
'''to contain all InCriteriaTest Unit Tests
'''</summary>
<TestClass()> _
Public Class FreeTextCriteriaTest


    Private testContextInstance As TestContext

    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(value As TestContext)
            testContextInstance = value
        End Set
    End Property


    <TestMethod()> _
    Public Sub FreeTextCriteria_Test1()

        Dim Qry As New QBuilder.SelectQuery

        Qry.TableName = "test"
        Qry.Fields.Add("a")
        Qry.Fields.Add("b")
        Qry.Fields.Add("c")

        Qry.AddCriteria(New FreeTextCriteria("a=15"))
        Dim expected As String = "SELECT a, b, c FROM test WHERE a=15"
        Dim actual As String = Qry.GetSQLText()

        Assert.AreEqual(expected, actual)
    End Sub

    <TestMethod()> _
    Public Sub FreeTextCriteria_Test2()

        Dim Qry As New QBuilder.SelectQuery

        Qry.TableName = "test"
        Qry.Fields.Add("a")
        Qry.Fields.Add("b")
        Qry.Fields.Add("c")

        Qry.AddCriteria(New FreeTextCriteria("@Field1='Cookie%'"))
        Dim expected As String = "SELECT a, b, c FROM test WHERE @Field1='Cookie%'"
        Dim actual As String = Qry.GetSQLText()

        Assert.AreEqual(expected, actual)
    End Sub

    <TestMethod()> _
    Public Sub FreeTextCriteria_GetText()

        Dim Qry As New FreeTextCriteria("FieldA = 1")
        Assert.AreEqual("FieldA = 1", Qry.GetText)
    End Sub
End Class